/**
 ****************************************************************
 * @file main.c
 *
 * @brief  main entry of test.
 *
 * @author 
 *
 * 
 ****************************************************************
 */ 

/*
 * INCLUDE FILES
 ****************************************************************
 */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include <logging/log.h>

#include "define.h"

#include "timer.h"

#include "nfc663.h"
#include "rfid.h"

#include "iso14443a.h"
#include "iso14443b.h"
#include "iso14443_4.h"


void test_mh663_main(void)
{
	u8 cmd[2];
	u8 status_a = 1, status_b = 1;
	
	LOG_INF("start...\n");

	pcd_init();//初始化pcd寄存器
	rfid_init();//初始化rfid本地变量

	while(1)
	{
		
		pcd_antenna_off();
		mdelay(100);
		pcd_antenna_on();
		
		mdelay(10);
		
		pcd_config('A');
		
		
		cmd[1] = 0x52;
			
		status_a = com_reqa(cmd);//询所有A卡		
		if(!status_a){
			LOG_BUF(0, RTT_CTRL_TEXT_BRIGHT_WHITE, "uida", g_tag_info.serial_num, g_tag_info.uid_length);
		}
		mdelay(10);
		pcd_config('B');
		cmd[1] = 0x08;
		status_b = com_reqb(cmd);//询所有B卡
		if(!status_b){
			u8 sfz[10];
			int ret = get_idcard_num(sfz);
			if(!ret){
				LOG_BUF(0, RTT_CTRL_TEXT_BRIGHT_WHITE, "sfz", sfz, 8);
			}
		}
	}		
}

